package com.example.ceshi.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.ceshi.Bean.DataDetail;
import com.example.ceshi.Bean.LogisticsTraceDetails;
import com.example.ceshi.R;

import java.util.List;

public class DetailAdapter2 extends BaseAdapter {
    private List<LogisticsTraceDetails> logisticsTraceDetailsList;
    private LayoutInflater mLayoutInflater;
    private Context mContext;

    public DetailAdapter2(Context context, List<LogisticsTraceDetails> logisticsTraceDetailsList) {
        this.mContext = context;
        this.logisticsTraceDetailsList = logisticsTraceDetailsList;
        mLayoutInflater = LayoutInflater.from(mContext);
    }


    @Override
    public int getCount() {
        return logisticsTraceDetailsList.size();
    }

    @Override
    public Object getItem(int i) {
        return logisticsTraceDetailsList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup parent) {

        ViewHolder viewHolder=new ViewHolder();


        if (view == null) {
            view = mLayoutInflater.inflate(R.layout.list_item_detail, parent, false);

            ImageView imageView =view.findViewById(R.id.myicon);
            TextView text_place = view.findViewById(R.id.place);
            TextView text_detail = view.findViewById(R.id.detail);

            viewHolder.imageView=imageView;
            viewHolder.text_detail=text_detail;
            viewHolder.text_place=text_place;


            view.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) view.getTag();
        }

        LogisticsTraceDetails logisticsTraceDetails = logisticsTraceDetailsList.get(i);

//        viewHolder.imageView
        viewHolder.text_detail.setText(logisticsTraceDetails.getDesc());
        viewHolder.text_place.setText(logisticsTraceDetails.getAreaName());


        return view;
    }


    class ViewHolder {
        ImageView imageView;
        TextView text_place;
        TextView text_detail;
    }
}
